<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8"></meta>
		<meta content="width=device-width,initial-scale=1" name="viewport">
		<title>proxy 双向绑定</title>
	</head>
	<body>
        <input id="inputid" oninput="onHandle(this)">
        <br/>
        <div id="showdiv"></div>
	</body>
</html>
<script>
function proxyObj(target){
    return new Proxy(target,{
        get(obj,prop){
            return obj[prop]
        },
        set(obj, prop, value){
            obj[prop] = value
            document.getElementById("showdiv").innerText = obj[prop] 
            return
        },
    })
}

let obj = {
    value:"hello world"
}

let obj_proxy = proxyObj(obj)

;(function(){
    document.getElementById("showdiv").innerText = obj_proxy.value
})()

function onHandle(e){
    obj_proxy.value = e.value
}

</script>